home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8291 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  44 lines

  1. Path: castle.nando.net!news
  2. From: actuary@nando.net   (Bill McCarthy)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: passing arguments to main()
  5. Date: 3 Mar 1996 00:03:13 GMT
  6. Organization: Nando.net Public Access
  7. Message-ID: <4hank1$k36@castle.nando.net>
  8. References: <4h78t1$nqq@netnews.upenn.edu>
  9. Reply-To: actuary@nando.net (Bill McCarthy)
  10. NNTP-Posting-Host: grail1703.nando.net
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4h78t1$nqq@netnews.upenn.edu>, daniels@oasis.rad.upenn.edu (Jamie Daniels) writes:
  14. >Hello,
  15. >
  16. >I have a question about c I am not very good with programming. I have this 
  17. >project that I want to take two strings one a name the other being an 80
  18. >character message(sentence). I want it to spit out a simplt print statement at
  19. >an Unix prompt. But I don't know how to pass arguments to main(). also I can't 
  20. >get the output to be entered in at the unix prompt. I want the output to be a 
  21. >command. for a simple example
  22. >
  23. > printf("ping 165.234.323.222");
  24. >
  25. >will not ping this address it only prints this statement before the prompt
  26. >
  27. > any help would be greatly appreciated
  28.  
  29. I'm not familiar with Unix (although I've worked a bit with Linux), so there
  30. may be a preferably way to do this in a Unix environment.  The ANSI C
  31. approach would be:
  32.  
  33. #include <stdlib.h>
  34.  
  35. int main( void )
  36. {
  37.    system( "ping 165.234.323.222" );
  38.    return EXIT_SUCCESS;
  39. }
  40.  
  41. Bill McCarthy
  42. actuary@nando.net
  43. Wendell, NC  USA
  44.